package com.hhx.androidrxmvp.ui;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.hhx.androidrxmvp.R;
import com.hhx.androidrxmvp.base.BaseMvpActivity;
import com.hhx.androidrxmvp.bean.BaseResp;
import com.hhx.androidrxmvp.bean.Login;
import com.hhx.androidrxmvp.mvp.contract.LoginContract;
import com.hhx.androidrxmvp.mvp.presenter.LoginPresenter;
import com.hhx.androidrxmvp.utils.LogUtil;

import java.util.HashMap;

/**
 * Dagger2注入
 */
public class LoginActivity extends BaseMvpActivity<LoginPresenter> implements LoginContract.View {

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_login;
    }

    @Override
    protected void initInjector() {
        getActivityComponent().inject(this);
    }

    @Override
    protected void initView(Bundle savedInstanceState) {

    }

    public void onLoginClick(View view) {
        HashMap<String, String> map = new HashMap<>();
        map.put("phone", "18245083860");
        map.put("password", "123456");
        map.put("j_push_id", "123456");
        //showLoading();
        mPresenter.loginNormal(map);
    }

    @Override
    public void refreshSuccess(BaseResp<Login> baseResp) {
        if (baseResp.getCode() == 1) {
            Login login = baseResp.getData();
            LogUtil.d(TAG, "login：" + login.getNike_name());
        } else {
            Toast.makeText(this, baseResp.getMsg(), Toast.LENGTH_SHORT).show();
        }
        //hideLoading();
    }

    @Override
    public void refreshFailed(String msg) {
        //hideLoading();
    }
}
